如何消除python中的VisibleDeprecationWarning\ DeprecationWarning等类似警告: | 您所在的位置:网站首页 › python 去掉警告 › 如何消除python中的VisibleDeprecationWarning\ DeprecationWarning等类似警告: |
我们在写相关代码时总会有一些警告,虽然并不影响结果,但是很影响美观。如果在不急于解决警告的情况下我们可以选择一些方法进行忽略。 eg: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; DeprecationWarning: This function is deprecated. Please call randint(0, 1 + 1) instead; 添加代码如下: import warnings warnings.filterwarnings("ignore", category=Warning)利用相关的正则进行所出现的警告匹配,如果需要更多的操作,可以深入学习warnings模块 更好的认知和阅读体验请扫它吧![]() |
CopyRight 2018-2019 实验室设备网 版权所有 |